//Tue Jun  7 12:26:41 CDT 2011
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

class FlowerGarden {
public:
	vector <int> getOrdering(vector <int>, vector <int>, vector <int>);
};

vector <int> FlowerGarden::getOrdering(vector <int> height, vector <int> bloom, vector <int> wilt) {
	vector<int> ret;
	vector<pair<int, pair<int, int> > > flower;
	int N = height.size();
	for(int i=0; i<N; i++){
		flower.push_back(make_pair(height[i], make_pair(bloom[i], wilt[i])));
	}
	sort(flower.begin(), flower.end());
	bool grid[51][51];
	bool used[51];
	memset(grid, false, sizeof(grid));
	memset(used, false, sizeof(used));
	
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			if(flower[i].second.second < flower[j].second.first || flower[i].second.first > flower[j].second.second){
				grid[i][j] = true;
				grid[j][i] = true;
			}
		}
	}
	
	for(int i=0; i<N; i++){
		int j;
		for(j=N-1; j>=0; j--){
			if(!used[j]){
				bool flag = true;
				for(int k=0; k<j; k++){
					if(!used[k] && !grid[k][j]) flag = false;
				}
				if(flag) break;
			}
		}
		used[j] = true;
		ret.push_back(flower[j].first);
	}
	return ret;
}

//<%:testing-code%>
//Powered by [KawigiEdit] 2.0!
